#include "logicUnaryOperation.h"
LogicUnaryOperation::LogicUnaryOperation(std::string opRep, Expression* expression)
{
	if(expression != NULL) Operand=expression->clone();
	else Operand = NULL;
	operatorRepresentation=opRep;
}

LogicUnaryOperation::LogicUnaryOperation(const LogicUnaryOperation & other)
{
    if(other.Operand != NULL) this->Operand = other.Operand->clone();
    else this->Operand = NULL;
    operatorRepresentation = other.operatorRepresentation;
}

LogicUnaryOperation::~LogicUnaryOperation()
{
    delete Operand; Operand = NULL;
    operatorRepresentation = "";
}

Expression * LogicUnaryOperation::clone()
{
    return new LogicUnaryOperation(*this);
}

std::string LogicUnaryOperation::toString()
{
    std::string str = "("+operatorRepresentation;
    if(Operand != NULL) str = str + " " + Operand->toString();
    return str+")";
}

Expression * LogicUnaryOperation::getExpression()
{
    return Operand;
}

void LogicUnaryOperation::setExpression(Expression * expression)
{
  if (expression == Operand) return;
    delete Operand; Operand = NULL;
    if(expression != NULL) Operand = expression->clone();
}

void LogicUnaryOperation::setOperator(const std::string & opRep)
{
    operatorRepresentation = opRep;
}

std::string LogicUnaryOperation::getOperator()
{
    return operatorRepresentation;
}
